// 4.0 获取菜单数据
import axios from "../../utils/axios"

export default {
    namespaced: true,
    state() {
        return {
            goodsmList: [],
            goodsmCount:0,
        }
    },
    mutations: {
        saveGoodsMListMutations(state, list) {
            console.log("saveGoodsMListMutations执行了")
            console.log(list)
            state.goodsmList = list
        },
        saveGoodsMCountListMutations(state,count){
            state.goodsmCount= count
          
        }
    },
    actions: {
        getGoodsMListActions({commit},pagesinfo) {
            console.log("getGoodsMListActions执行了")
            axios({
                method: 'GET',
                url: '/api/goodslist',
                params:pagesinfo
            }).then( response => {
                // 关联上下级菜单数据
                console.log(response)
                // let pmenus = response.list.filter(item => item.pid === 0)
                // pmenus.forEach(pitem => {
                //     pitem.children = []
                //     response.list.forEach(item => {
                //         if (item.pid === pitem.id) {
                //             pitem.children.push(item)
                //         }
                //     })
                // })

                commit('saveGoodsMListMutations', response.list)
                
            })
        },
        getGoodsMCountListActions({commit}){
           axios({
            method: 'GET',
            url: '/api/goodscount',
            
           }).then(response=>{
            commit('saveGoodsMCountListMutations',response.list[0].total||0)
            console.log(response.list,"!!!!!!!!!!!!!!!!!!!!!!!!!!!")
           })
        }
        
    },
    getters: {}
}


